#!/usr/bin/env sh
# yabai
# ---
# See: https://github.com/koekeishiya/yabai/wiki/Configuration
#      https://github.com/koekeishiya/yabai/blob/master/doc/yabai.asciidoc
#
# Reload: yabai --restart-service

sudo yabai --load-sa
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"

# Reload when displays change
yabai -m signal --add event=display_added   action="yabai --restart-service"
yabai -m signal --add event=display_removed action="yabai --restart-service"
yabai -m signal --add event=display_resized action="yabai --restart-service"
yabai -m signal --add event=display_moved   action="yabai --restart-service"

yabai -m config \
	external_bar               all:0:0      \
	mouse_follows_focus        off          \
	focus_follows_mouse        off          \
	window_zoom_persist        off          \
	window_placement           second_child \
	window_topmost             off          \
	window_shadow              float        \
	window_opacity             on           \
	window_opacity_duration    0.2          \
	active_window_opacity      1.0          \
	normal_window_opacity      1.0          \
	window_animation_duration  0.3          \
	insert_feedback_color      0xff9dd274   \
	split_ratio                0.50         \
	auto_balance               off          \
	auto_padding               on           \
	mouse_modifier             fn           \
	mouse_action1              move         \
	mouse_action2              resize       \
	mouse_drop_action          swap         \
	\
	top_padding                8            \
	bottom_padding             8            \
	left_padding               8            \
	right_padding              8            \
	window_gap                 8

yabai -m rule --add app="^(LuLu|Calculator|Software Update|Dictionary|VLC|System Preferences|System Settings|zoom.us|Photo Booth|Archive Utility|Python|LibreOffice|App Store|Steam|Alfred|Activity Monitor)$" manage=off
yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off
yabai -m rule --add label="Safari" app="^Safari$" title="^(General|(Tab|Password|Website|Extension)s|AutoFill|Se(arch|curity)|Privacy|Advance)$" manage=off
yabai -m rule --add label="About This Mac" app="System Information" title="About This Mac" manage=off
yabai -m rule --add label="Select file to save to" app="^Inkscape$" title="Select file to save to" manage=off

# Apps
yabai -m rule --add app='^Bartender .$'        manage=off
yabai -m rule --add app='^Beyond Compare$'     manage=off
yabai -m rule --add app='^Calendar$'           manage=off
yabai -m rule --add app='^ColorSlurp$'         manage=off
yabai -m rule --add app='^Contexts$'           manage=off
yabai -m rule --add app='^Dozer$'              manage=off
yabai -m rule --add app='^FortiClient$'        manage=off
yabai -m rule --add app='^Karabiner-Elements$' manage=off
yabai -m rule --add app='^Maccy$'              manage=off
yabai -m rule --add app='^Monosnap$'           manage=off
yabai -m rule --add app='^Pixelmator'          manage=off
yabai -m rule --add app='^Raycast$'            manage=off
yabai -m rule --add app='^Reminders$'          manage=off

# Placement
yabai -m rule --add app='^App Store$'        grid=24:24:1:1:22:22
yabai -m rule --add app='^Dictionary$'       grid=24:24:15:1:8:14
yabai -m rule --add app='^Docker Desktop$'   manage=off grid=4:4:1:1:2:2
yabai -m rule --add app='^Marked 2$'         manage=off layer=above grid=1:2:1:0:1:1
yabai -m rule --add app='^Preview$'          manage=off grid=1:2:1:0:1:1

# yabai -m rule --add app='^Dictionary$'       manage=off layer=above grid=24:24:15:1:8:14
# yabai -m rule --add app='^Preview$'          manage=off layer=above grid=1:2:1:0:1:1
# yabai -m rule --add app='^Dash$'             manage=off layer=above grid=1:2:1:0:1:1
# yabai -m rule --add app='^Docker$'           manage=off layer=above border=off
# yabai -m rule --add app='^Docker Desktop$'   manage=off layer=above border=off grid=4:4:1:1:2:2
# yabai -m rule --add app='^Dozer$'            manage=off layer=above border=off
# Borders
# /opt/homebrew/bin/borders active_color=0xff84153D inactive_color=0xff494d64 width=5.0 2>/dev/null 1>&2 &

yabai -m config layout bsp  # bsp, float

# vim: set ts=2 sw=2 tw=80 noet :
